package com.neca.auction.pages;

import org.apache.tapestry.annotations.OnEvent;
import org.apache.tapestry.annotations.Persist;

import com.neca.auction.dbb.DBBroker;
import com.neca.auction.model.Product;

public class EditProduct {
	
	
	@Persist
	private Product product;
	private boolean delete=false;
	
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	
	void onSubmitFromProductEditor(){
		System.out.println("The form was submitted!!!");
		
	}
	
	void onValidate(){
		
	}
	Object onSuccess(){
		if(delete==false){
		DBBroker dbbroker=DBBroker.getDbbroker();
		dbbroker.addProduct(product);
		return MyProducts.class;
		}else{
		return MyProducts.class;
		}
		
	}
	
	@OnEvent(component="deleteButton")
	void onDeleteButton(){
		System.out.println("sdfsdfdsfdsfdsfdsfsdfsdfsfdsfdsfaaaaaaa");
		DBBroker dbbroker=DBBroker.getDbbroker();
		dbbroker.removeProduct(product);
		delete=true;
		
	}
	
}
